<?php

namespace app\student\controller;

use app\student\model\teacherLoginModel;
use http\Header;
use think\App;

class TeacherLogin extends \think\Controller
{
    public function __construct(App $app = null)
    {
        parent::__construct($app);

        $result = session('t_name');
        if($result)
        {
            return $result;
        }else{
            return $this->fetch('Login/teacherLogin');
        }
    }


    public function teacherLogin()
    {
        if($this->request->isPost())
        {
            $teacher = $this->request->post();
            $result = teacherLoginModel::teacherLogin($teacher);
            if($result)
            {
                session('t_name',$result);
                //header('Location:/student/Teacher_Base/teacherBase');
                echo"<a href='/student/Teacher_Base/teacherBase'>登录成功</a>";
            }else{
                return $this->error('登录失败','/student/Teacher_Login/teacherLogin');
            }


        }else{

            return $this->fetch('Login/teacherLogin');
        }




    }
}